<template>
  <ekDialog
    v-model="ekVisiable"
    :title="title"
    @submit="handleSubmit"
    :hideBtn="disabled"
  >
    <div class="ek-form" v-loading="loading">

      {{ form.pay_message}}
    </div>
  </ekDialog>
</template>

<script setup>
import {
  watch,
  getCurrentInstance,
  computed,
  reactive,
  ref,
  defineEmits,
  onMounted,
} from "vue";
import { apis } from "../data.js";
import ekDialog from "@/components/business/ekDialog/index.vue";

import { objectAssignment } from "@/utils/common.js";
import { getDimensionByCode } from "@/utils/sys.js";
const props = defineProps({
  // 显示隐藏
  visiable: {
    type: Boolean,
    default: false,
  },
  rowId: {
    type: [String, Number],
    default: "",
  },
  title: {
    type: String,
    default: "",
  },
  disabled: {
    type: Boolean,
    default: false,
  },
});
const {
  appContext: {
    config: { globalProperties },
  },
} = getCurrentInstance();
const { $storage, $http, $ekLoading, $ekMessage } = globalProperties;

const emit = defineEmits(["update:visiable", "submit"]);

// 是否显示
const ekVisiable = computed({
  get() {
    return props.visiable;
  },
  set(value) {
    emit("update:visiable", value);
  },
});


const loading = ref(false);
let form = ref(null);
const initForm = () => {
  form.value = {
    pay_message: ''
  };
};

// 初始化表单
async function init() {
  loading.value = true;
  // 详情或者编辑
  $http
    .get(apis.detail, {
      params: {
        id: props.rowId || null,
      },
    })
    .then((res) => {
      if (Object.keys(res.data).length) {
        form.value.pay_message= res.data.pay_message
        objectAssignment(form.value, res.data);
      }
      loading.value = false;
    });
}

watch(
  () => props.visiable,
  (val) => {
    if (val) {
      initForm();
      init();
    }
  }
);

</script>

<style scoped lang="scss"></style>
